/*
 * Created by SharpDevelop.
 * User: David
 * Date: 2006-11-24
 * Time: 22:05
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;

namespace Labb4.Entity
{
	/// <summary>
	/// Basic Control class, for controlling the movement of an entity.
	/// </summary>
	public abstract class Control //strategy
	{
		#region members
		
		/// <summary>
		/// An enum listing all the keys in a keypad controlling an entity
		/// </summary>
		public enum PadKey
		{
			UP = 87,				//w
			DOWN = 83,				//s
			
			SOFT_LEFT = 81,			//q
			MEDIUM_LEFT = 65,		//a
			HARD_LEFT = 90,			//z
			
			SOFT_RIGHT = 69,		//e
			MEDIUM_RIGHT = 68,		//d
			HARD_RIGHT = 67,		//c
			
			MEDIUM_SPEED = 17,		//<ctrl>
			HIGH_SPEED = 16,		//<shift>
			
			ANIM_0 = 48,			//0
			ANIM_1 = 49,			//1
			ANIM_2 = 50,			//2
			ANIM_3 = 51,			//3
			ANIM_4 = 52,			//4
			ANIM_5 = 53,			//5
			ANIM_6 = 54,			//6
			ANIM_7 = 55,			//7
			ANIM_8 = 56,			//8
			ANIM_9 = 57,			//9
		};
		
		/// <summary>
		/// A reference to the entity that this Control controls.
		/// </summary>
		protected BasicEntity		m_Entity;
		
		#endregion
		
		#region constructors
		
		/// <summary>
		/// Constructor of Control, sets the entity reference to null, and registers the control
		/// with the <see cref="ControlManager">control manager</see>.
		/// </summary>
		public Control()
		{
			m_Entity = null;
			
			ControlManager.Instance.AddControl(this);
		}
		
		#endregion
		
		#region virtuals
		
		/// <summary>
		/// Updates the AI, if this control has one. Here the AI does certain estimates to help it
		/// decide what buttons to push, or what direction/velocity to take.
		/// </summary>
		/// <param name="deltaTime">The time passed since the last update. Unit is (ms)</param>
		public virtual void UpdateAI(ref int deltaTime) {}
		/// <summary>
		/// Updates the entity's different attributes in accordance with the attributes of the controler.
		/// </summary>
		/// <param name="deltaTime">The time passed since the last update. Unit is (ms)</param>
		public virtual void UpdateEntity(ref int deltaTime) {}
		/// <summary>
		/// Adds a destination to the controler, if it's of type ControlDestination.
		/// </summary>
		/// <param name="x">The destinations x coordinate</param>
		/// <param name="y">The destinations y coordinate</param>
		/// <param name="speed">The speed at which to travel to this destination</param>
		public virtual void AddDestination(int x, int y, float speed) {}
		
		#endregion
		
		#region properties
		
		/// <summary>
		/// The entity this controler should control (set/get)
		/// </summary>
		public BasicEntity Entity
		{
			get
			{
				return m_Entity;
			}
			
			set
			{
				m_Entity = value;
			}
		}
		
		#endregion
	}
}
